{App::registerCoreScript('jquery')}
{App::registerCoreScript('base')}
{App::registerScript('inc/Modules/Clubs/js/categories_list.js')}

<h1>Категории клубов{if $parent}. {$parent->title}{/if}</h1>
<table class="list">
	<tr>
		<th class="_20">Ред.</th>
		<th>Название</th>
		<th class="_20">Удл.</th>
	</tr>
	{foreach $categories as $category}
		<tr>
			<td class="center">
				<a href="#" rel="{$category->id}" class="edit_club_cat"><img src="{$tpl_url}images/pencil.png"/></a>
			</td>
			<td>
				<div id="club_cat_title_{$category->id}">
					{if $category->parent == 1}
						<a href="{$base_url}&action=categories_list&parent={$category->id}">{$category->title}</a>
					{else}
						<a href="{$base_url}&action=clubs_list&category={$category->id}">{$category->title}</a>
					{/if}
				</div>
				<form style="display: none" action="{$base_url}&action=categories_save" class="club_cat_edit" id="club_cat_edit_{$category->id}">
					<input type="hidden" name="category[id]" value="{$category->id}" />
					<input type="hidden" name="category[parent]" value="{$category->parent}" />
					<input type="text" name="category[title]" value="{$category->title}" style="width: 300px;" />
					<input type="submit" value=" " class="plus" style="background-image: url({$tpl_url}images/folder_card_save.png)" />
					<input type="reset" value=" " class="cancel" title="[Esc]" rel="{$category->id}"/>
				</form>
			</td>
			<td class="center">
				<a class="delete" title="Удаление категории приведет к удалению всех подкатегорий и клубов в ней. Продолжить?" href="{$base_url}&action=categories_delete&id={$category->id}"><img src="{$tpl_url}images/trash.png"/></a>
			</td>
		</tr>
	{/foreach}
</table>

<form action="{$base_url}&action=categories_save" method="post">
	<input type="hidden" name="category[parent]" value="{if $parent}{$parent->id}{else}1{/if}" />
	<input type="text" name="category[title]" style="width: 300px;" />&nbsp;<input type="submit" value="Добавить" style="background-image: url({$tpl_url}images/folder_card_plus.png)" class="plus" />
</form>